from django.db import models


class Author(models.Model):
    name = models.CharField(max_length=255, verbose_name='姓名')
    birthday = models.DateTimeField(verbose_name="出生日期")  # 出生日期
    icon = models.CharField(max_length=255, verbose_name='图片路径')  # 图片路径
    introduce = models.TextField(verbose_name='作者简介')  # 作者
    phone = models.CharField(max_length=11, verbose_name='电话号码')
    email = models.EmailField(verbose_name='邮箱')

    class Meta:
        verbose_name_plural = verbose_name = '作者'
        # db_table=""

    def __str__(self):
        return self.name


# Create your models here.
class Blog(models.Model):
    title = models.CharField(max_length=255,verbose_name="标题")
    content = models.TextField(verbose_name='内容')
    created_time = models.DateTimeField(auto_now_add=True)  # 创建时间
    update_time = models.DateTimeField(auto_now=True)  # 修改时间
    author = models.ForeignKey(Author, on_delete=models.CASCADE)

    # author = models.ForeignKey(Author,on_delete=models.SET_NULL)

    class Meta:
        verbose_name_plural = verbose_name = "博客"

    def __str__(self):
        return self.title
